package com.xindong.paking.controller;

import com.xindong.paking.dtos.ParkingLotDTO;
import com.xindong.paking.entity.ParkingLot;
import com.xindong.paking.service.ParkingLotService;
import com.xindong.paking.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/parking/parking-lot")
@Api(tags = "停车场管理模块")
public class ParkingLotController {


    @Autowired
    private ParkingLotService parkingLotService;

    @GetMapping("queryByConForPage")
    @ApiOperation("根据条件停车场信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "停车场id"),
            @ApiImplicitParam(name = "name", value = "停车场名称"),
            @ApiImplicitParam(name = "des", value = "停车场描述"),
            @ApiImplicitParam(name = "unit_price", value = "单价，查询返回小于等于"),
            @ApiImplicitParam(name = "park_total", value = "停车位总数，查询返回大于等于"),
            @ApiImplicitParam(name = "park_re_quatity", value = "空闲车位数量，查询返回大于等于"),
            @ApiImplicitParam(name = "charg_total", value = "充电桩总数量，查询返回大于等于"),
            @ApiImplicitParam(name = "charg_re_quatity", value = "充电桩可用数量，查询返回大于等于"),
            @ApiImplicitParam(name = "status", value = "状态：1、生效，2、失效，3、已结束"),
            @ApiImplicitParam(name = "pageCount", value = "页码,默认为第一页"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数,默认每页10条")
    })
    public Result queryByConForPage(ParkingLotDTO dto) {
        return parkingLotService.queryByConForPage(dto);
    }

    @PostMapping("deleteById")
    @ApiOperation("根据id删除停车场信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "parkingLotId", value = "主键id")
    })
    public Result deleteById(@RequestParam("parkingLotId") Integer parkingLotId) {

        return parkingLotService.deleteById(parkingLotId);
    }


    @GetMapping("queryDetailById")
    @ApiOperation("根据id查询停车场详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "couponId", value = "主键id")
    })
    public Result queryDetailById(@RequestParam("parkingLotId") Integer parkingLotId){
        return parkingLotService.queryDetailById(parkingLotId);
    }


    @PostMapping("insertParkingLot")
    @ApiOperation("添加停车场信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "停车场名称"),
            @ApiImplicitParam(name = "des", value = "停车场描述"),
            @ApiImplicitParam(name = "unit_price", value = "单价，查询返回小于等于"),
            @ApiImplicitParam(name = "park_total", value = "停车位总数，查询返回大于等于"),
            @ApiImplicitParam(name = "park_re_quatity", value = "空闲车位数量，查询返回大于等于"),
            @ApiImplicitParam(name = "charg_total", value = "充电桩总数量，查询返回大于等于"),
            @ApiImplicitParam(name = "charg_re_quatity", value = "充电桩可用数量，查询返回大于等于"),
            @ApiImplicitParam(name = "status", value = "状态：1、生效，2、失效，3、已结束")
    })
    public Result insertParkingLot(@RequestBody ParkingLot dto) {
        return parkingLotService.insertParkingLot(dto);
    }


    @PostMapping("updateParkingLot")
    @ApiOperation("更新停车场信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "停车场id"),
            @ApiImplicitParam(name = "name", value = "停车场名称"),
            @ApiImplicitParam(name = "des", value = "停车场描述"),
            @ApiImplicitParam(name = "unitPrice", value = "单价，查询返回小于等于"),
            @ApiImplicitParam(name = "parkTotal", value = "停车位总数，查询返回大于等于"),
            @ApiImplicitParam(name = "parkReQuatity", value = "空闲车位数量，查询返回大于等于"),
            @ApiImplicitParam(name = "chargTotal", value = "充电桩总数量，查询返回大于等于"),
            @ApiImplicitParam(name = "chargReQuatity", value = "充电桩可用数量，查询返回大于等于"),
            @ApiImplicitParam(name = "status", value = "状态：1、生效，2、失效，3、已结束")
    })
    public Result UpdateParkingLot(@RequestBody ParkingLot dto) {
        return parkingLotService.UpdateParkingLot(dto);
    }

    @GetMapping("list")
    @ApiOperation("获取停车场列表")
    public Result getList() {
        return parkingLotService.getList();
    }
}
